-
Notifications
You must be signed in to change notification settings - Fork 0
Feat#19 회원,학교 목록 가져오기 #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
|
|
||
| @RequiredArgsConstructor | ||
| @RestController | ||
| @RequestMapping("/api/colleges") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
스펙상 rest api 앞에는 /api가 붙지 않습니다~
|
|
||
| private final CollegeService collegeService; | ||
|
|
||
| @GetMapping("/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rest api 규칙 중 마지막에 /가 붙지 않는 규칙이 있습니다.
| public ResponseEntity<List<College>> findAll(){ | ||
|
|
||
| List<College> college = collegeService.printAll(); | ||
| return ResponseEntity.status(HttpStatus.CREATED).body((List<College>) college); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HttpStatus.CREATED 보다 HttpStatus.OK 가 더 적합한 것 같습니다~
| private final TagService tagService; | ||
|
|
||
| @GetMapping("/") | ||
| public ResponseEntity<List<Tag>>findAll(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
커밋 전 idea의 포메팅 기능 이용을 부탁드립니다!
| public ResponseEntity<List<Tag>>findAll(){ | ||
|
|
||
| List<Tag> tag = tagService.printAll(); | ||
| return ResponseEntity.status(HttpStatus.CREATED).body((List<Tag>) tag); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HttpStatus.CREATED 보다 HttpStatus.OK 가 더 적합한 것 같습니다~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(List)를 통해 형변환이 이루어지고 있는데,
불필요한 코드 같습니다!
| } | ||
|
|
||
|
|
||
| public List<Tag> printAll(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
함수의 기능상 printAll()보다 findAll()이 더 적합한 것 같습니다!
| private CollegeRepository collegeRepository; | ||
|
|
||
|
|
||
| public List<College> printAll(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
함수의 기능상 printAll()보다 findAll()이 더 적합한 것 같습니다!
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| @Column(unique = true, insertable = false, updatable = false, length = 10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
컬럼 조건을 상세하게 지정해주셨네요 👍👍
|
|
||
| http.authorizeHttpRequests() | ||
| .anyRequest().authenticated(); | ||
| .anyRequest().permitAll(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
insomnia 사용하실 때만 임시로만 부탁드리겠습니다
| import java.util.List; | ||
| @RequiredArgsConstructor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ctrl + Alt + L 단축키 사용하셔서 포매팅 부탁드립니다~
| public List<College> findAll() { | ||
| return collegeRepository.findAll(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Controller <-> Service간에 데이터를 전달할 때는 entity 보다는 dto를 사용하는 것이 좋습니다~
| public List<Tag> findAll(){ | ||
| return tagRepository.findAll(); } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Controller <-> Service간에 데이터를 전달할 때는 entity 보다는 dto를 사용하는 것이 좋습니다~
|
|
||
| @Getter | ||
| @Entity | ||
| @Table(name = "College") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
보통 데이터베이스 테이블 이름, 컬럼과 같은 곳에는 소문자만을 사용하는 것이 기본 컨벤션입니다.
| @ManyToMany | ||
| @JoinTable(schema = "College") | ||
| private List<College> users = new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
collages가 조금 더 적합한 네이밍일 것 같습니다~
| @Getter | ||
| public class CollegeResponse { | ||
|
|
||
| private final Long id; | ||
| private final String collegeName; | ||
|
|
||
|
|
||
| public CollegeResponse(College college){ | ||
|
|
||
| this.id = college.getId(); | ||
| this.collegeName = college.getName(); | ||
|
|
||
| } | ||
|
|
||
|
|
||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요즘 dto를 만들 때는 record를 사용하시면 편리합니다~
| @Getter | ||
| public class TagResponse { | ||
|
|
||
| private final Long id; | ||
| private final String user; | ||
|
|
||
|
|
||
| public TagResponse(Tag tag){ | ||
| this.id = tag.getId(); | ||
| this.user = tag.getName(); | ||
| } | ||
|
|
||
|
|
||
| } No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요즘 dto를 만들 때는 record를 사용하시면 편리합니다~
| public ResponseEntity<List<College>> findAll(){ | ||
|
|
||
| List<College> college = collegeService.findAll(); | ||
| return ResponseEntity.status(HttpStatus.OK).body((List<College>) college); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ResponseEntity.ok(body)를 사용하시면 조금 더 간결하고 편리하게 사용하실 수 있을 것 같습니다~
|
|
||
| private final TagService tagService; | ||
| List<Tag> tag = tagService.findAll(); | ||
| return ResponseEntity.status(HttpStatus.OK).body(tag); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ResponseEntity.ok(body)를 사용하시면 조금 더 간결하고 편리하게 사용하실 수 있을 것 같습니다~
No description provided.